home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
earcd
/
comm
/
mail
/
yamscrip.lha
/
Fileserver.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-12-05
|
3KB
|
78 lines
/* YAM file server. Version:1.1 11-Nov-96
The script understands 3 types of requests
1. request index - list of files in the directory. It's created when a
request is encountered, you don't need to do it yourself.
2. request help - send helpfile
request info
3. request <file> - send a file
Send comments, bug reports or hate mail to knikulai@utu.fi. You can also
test this script by sending mail to me.
*/
Options Results
folder=0 /* Number of the folder where messages are */
sdir='packed:FileServer/' /* Full path to the directory where files are kept */
helpname='packed:FileServer/HelpFile.txt' /* Full path to the helpfile */
call addlib('rexxsupport.library',0,-30,0)
/* YAM is probably already running, but let's be cautious */
if show('P','YAM')=0 then do /* YAM is not running yet, so let's start it */
address command 'run <>nil: yam:yam nocheck'
i=0
do until show('P','YAM')>0 | i=3 /* Let's not wait more than 30 seconds */
address command 'sys:rexxc/WaitForPort YAM'
i=i+1
end /* do */
if show('P','YAM')=0 then do /* Something went wrong, let's quit */
address command 'RequestChoice <>nil: "Error!" "Can not start YAM!" ":-("'
exit
end
end
/* Now we know YAM is up and running */
address 'YAM' 'SetFolder ' || folder /* Set current folder */
address 'YAM' 'GetFolderInfo MAX' /* How many messages are there? */
n=result
address command 'list >t:YFSindex.txt nohead dates ' || sdir
do i=0 to n-1 /* Process all messages */
address 'YAM' 'SetMail' i /* Set current message */
address 'YAM' 'GetMailInfo SUBJECT' /* Get subject line */
subj=upper(result)
address 'YAM' 'GetMailInfo FILE' /* get filename */
fs=statef(result)
fcomment=word(fs,words(fs)) /* get the last word (filenote) */
deleted=pos('D',fcomment)>0 /* true, if message was deleted */
if ~deleted & left(subj,8)='REQUEST ' then do
address 'YAM' 'MailDelete'
req=strip(word(subj,2)) /* What was requested? */
filename=sdir || req /* Default is a file */
if req='HELP' then filename=helpname
if req='INFO' then filename=helpname
if req='INDEX' then filename='t:YFSindex.txt'
address 'YAM' 'MailReply'
ft='text/plain'
/* Add the required filetypes here */
if pos('.GIF',req) >0 then ft='image/gif'
if pos('.JPG',req) >0 then ft='image/jpeg'
if pos('.MPG',req) >0 then ft='video/mpeg'
if pos('.WAV',req) >0 then ft='audio/basic'
if pos('.LHA',req) >0 then ft='application/octet-stream'
if pos('.LZH',req) >0 then ft='application/octet-stream'
if pos('.LZX',req) >0 then ft='application/octet-stream'
desc=' "" MIME '
address 'YAM' 'WriteAttach '|| filename || desc || ft
if ~exists(filename) then do
address 'YAM' 'WriteSubject "Requested file not found, index sent"'
address 'YAM' 'WriteLetter t:YFSindex.txt'
end
address 'YAM' 'WriteQueue'
end /*if left(subj,8)='REQUEST ' then*/
end /*do*/
address 'YAM' 'MailSendAll'
/* call delete('t:YFSindex.txt') */
exit